package net.sxnic.item.catalog;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import net.sxinfo.core.entity.AbstractEntity;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 类别管理
 * @author yfsun
 *
 */
@Entity
@Table(name = "item_catalog")
@BatchSize(size = 10)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Catalog extends AbstractEntity{

	private static final long serialVersionUID = 2209461224591491326L;
	
	/**
	 * 大类都是000，小类按顺序001,002来表示
	 */
	private String code;
	
	/**
	 * 名称
	 */
	private String name;
	
	/**
	 * 001大类 002小类
	 */
	private String cate;
	
	/**
	 * 只有大类才有 别名
	 */
	private String alias;
	
	/**
	 * 全名 基本不用
	 */
	private String fullName;
	
	/**
	 * 项目申报开始时间，一般在大类定义。格式：yyyy-MM-dd HH
	 */
	private String applyStartDate;
	
	/**
	 * 项目申报结束时间，一般在大类定义。格式：yyyy-MM-dd HH
	 */
	private String applyEndDate;
	
	/**
	 * 项目管理开始时间，一般在大类定义。格式：yyyy-MM-dd HH
	 */
	private String manageStartDate;
	
	/**
	 * 项目管理结束时间，一般在大类定义。格式：yyyy-MM-dd HH
	 */
	private String manageEndDate;
	
	private Integer priority;
	
	private Boolean treeLeaf;

	/**
	 * 父类别。小类的父类是大类，大类没有父类
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private Catalog parent;
	
	/**
	 * 子类别。大类的子类是小类别，小类别没有子类
	 */
	@ManyToMany(fetch=FetchType.LAZY)
	@OrderBy("code")
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	private List<Catalog> child;
	
	/**
	 * 操作年一般不用，在多个大类的系统中才启用，一个系统一个大类本字段没用
	 */
	private String optYear;
	
	/**
	 * 辅助排序字段
	 */
	private double xorder;

	public Catalog() {
		super();
		child = new ArrayList<Catalog>();
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCate() {
		return cate;
	}

	public void setCate(String cate) {
		this.cate = cate;
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getApplyStartDate() {
		return applyStartDate;
	}

	public void setApplyStartDate(String applyStartDate) {
		this.applyStartDate = applyStartDate;
	}

	public String getApplyEndDate() {
		return applyEndDate;
	}

	public void setApplyEndDate(String applyEndDate) {
		this.applyEndDate = applyEndDate;
	}

	public String getManageStartDate() {
		return manageStartDate;
	}

	public void setManageStartDate(String manageStartDate) {
		this.manageStartDate = manageStartDate;
	}

	public String getManageEndDate() {
		return manageEndDate;
	}

	public void setManageEndDate(String manageEndDate) {
		this.manageEndDate = manageEndDate;
	}

	public String getOptYear() {
		return optYear;
	}

	public void setOptYear(String optYear) {
		this.optYear = optYear;
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public Boolean getTreeLeaf() {
		return treeLeaf;
	}

	public void setTreeLeaf(Boolean treeLeaf) {
		this.treeLeaf = treeLeaf;
	}

	public Catalog getParent() {
		return parent;
	}

	public void setParent(Catalog parent) {
		this.parent = parent;
	}

	public List<Catalog> getChild() {
		return child;
	}

	public void setChild(List<Catalog> child) {
		this.child = child;
	}

	public double getXorder() {
		return xorder;
	}

	public void setXorder(double xorder) {
		this.xorder = xorder;
	}
	
	

}
